home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / msysjour / vol06 / 03 / lanman3 / phone.c < prev    next >
C/C++ Source or Header  |  1991-05-01  |  3KB  |  95 lines

  1.  
  2. //===================================================================
  3. //  MODULE: phone.c
  4. //===================================================================
  5.  
  6. #include "phone.h"
  7.  
  8. HWND hParent;        //... handle to parent window
  9.  
  10. //===================================================================
  11. //  WinMain()
  12. //
  13. //  The main entry point into phone.exe. Among onther things, we
  14. //  save the handle to the parent window in "hParent."
  15. //===================================================================
  16.  
  17. int PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
  18. HANDLE    hInstance;
  19. HANDLE    hPrevInstance;
  20. LPSTR    lpszCmdLine;
  21. int    nCmdShow;
  22. {
  23.     static char szAppName[] = "WinPhone";
  24.     MSG     msg;
  25.     WNDCLASS    wndclass;
  26.     short    xScreen, yScreen;
  27.     short    ulCol, ulRow, Width, Height;
  28.  
  29.     //===============================================================
  30.     //    Define Parent Window and Children classes
  31.     //===============================================================
  32.  
  33.     if ( !hPrevInstance )
  34.     {
  35.     wndclass.style        = CS_HREDRAW | CS_VREDRAW;
  36.     wndclass.lpfnWndProc    = WndProc;
  37.     wndclass.cbClsExtra    = 0;
  38.     wndclass.cbWndExtra    = 0;
  39.     wndclass.hInstance    = hInstance;
  40.     wndclass.hIcon        = LoadIcon(hInstance,(LPSTR)"phone");
  41.     wndclass.hCursor    = LoadCursor(NULL, IDC_ARROW);
  42.     wndclass.hbrBackground    = GetStockObject(WHITE_BRUSH);
  43.     wndclass.lpszMenuName    = PHONEMENU;
  44.     wndclass.lpszClassName    = szAppName;
  45.  
  46.     if ( !RegisterClass(&wndclass) )
  47.     {
  48.         return FALSE;
  49.     }
  50.     }
  51.  
  52.     //===============================================================
  53.     //    Create Parent and child windows
  54.     //===============================================================
  55.  
  56.     xScreen = GetSystemMetrics(SM_CXSCREEN);
  57.     yScreen = GetSystemMetrics(SM_CYSCREEN);
  58.  
  59.     ulCol  = 5 * xScreen / 80;
  60.     ulRow  = yScreen / 25;
  61.     Width  = 7 * xScreen / 8;
  62.     Height = 7 * yScreen / 8;
  63.  
  64.     hParent = CreateWindow(szAppName,           // window class
  65.                PROGNAME,           // window caption
  66.                WS_OVERLAPPEDWINDOW,// window style
  67.                ulCol,           // initial x pos
  68.                ulRow,           // initial y pos
  69.                Width,           // initial x size
  70.                Height,           // initial y size
  71.                NULL,           // parent window
  72.                NULL,           // window menu
  73.                hInstance,           // program instance
  74.                NULL);           // create parameters
  75.  
  76.     //===============================================================
  77.     //    Show window and update.
  78.     //===============================================================
  79.  
  80.     ShowWindow(hParent, nCmdShow);
  81.     UpdateWindow(hParent);
  82.  
  83.     //===============================================================
  84.     //    Enter Message loop
  85.     //===============================================================
  86.  
  87.     while( GetMessage(&msg, NULL, 0, 0) )
  88.     {
  89.     TranslateMessage(&msg);
  90.     DispatchMessage(&msg);
  91.     }
  92.  
  93.     return msg.wParam;
  94. }
  95.